package com.fanyue.modules.face.controller;

import cn.hutool.json.JSONObject;
import com.fanyue.core.annotation.CoolRestController;
import com.fanyue.core.annotation.TokenIgnore;
import com.fanyue.core.base.BaseController;
import com.fanyue.core.request.R;
import com.fanyue.modules.face.service.FaceEngineService;
import com.fanyue.modules.face.vo.FaceVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Tag(name = "测试CURD", description = "测试CURD")
@RestController
@AllArgsConstructor
@RequestMapping("/face/engine")
public class FaceEngineController {

	private final FaceEngineService faceEngineService;

	@GetMapping("/face/featureList")
	public R featureList() {
		return faceEngineService.featureList();
	}

	@PostMapping("/extract/feature")
	public R extractFeature(
		@RequestParam("userId") Long userId,
		@RequestParam("faceFile") MultipartFile file
	) {
		return faceEngineService.extractFeature("multipartFile", userId, file, null);
	}

	@PostMapping("/extract/feature4Office")
	public R feature4Office(@RequestBody FaceVO faceVO) {
		Long userId = faceVO.getUserId();
		String facePath = faceVO.getFacePath();
		return faceEngineService.extractFeature("filePath", userId, null, facePath);
	}

	@PostMapping("/select/feature")
	public R selectFeature(
		@RequestParam("cid") Long cid,
		@RequestParam("faceFile") MultipartFile file
	) {
		return faceEngineService.selectFeature(cid, file);
	}

	@PostMapping("/compare/feature")
	public R extractFeature(
		@RequestBody FaceVO faceVO
	) {
		return faceEngineService.compareFeature(faceVO);
	}

	@PostMapping("/compare/feature/base64")
	public R extractFeatureBase64(
		@RequestBody FaceVO faceVO
	) {
		return faceEngineService.compareFeatureBase64(faceVO);
	}


	@PostMapping("/delete/feature")
	public R deleteFeature(@RequestBody FaceVO faceVO) {
		Long userId = faceVO.getUserId();
		return faceEngineService.deleteFeature(userId);
	}


}
